package wiki.hitime.stl.list.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import wiki.hitime.stl.list.service.ListService;

/**
 * @author zhangdaoping
 * @create 2019-08-16 19:12
 */
@Controller
public class ListController {

    private ListService listService;

    public ListController(ListService listService) {
        this.listService = listService;
    }

    /**
     * 服务列表展示页
     *
     * @param modelMap
     * @return
     */
    @RequestMapping("/list")
    public String list(ModelMap modelMap) {
        modelMap.addAttribute("title", "服务列表");
        modelMap.addAttribute("serviceGroupList", listService.load());
        return "list";
    }

    /**
     * 重新加载服务列表
     *
     * @param modelMap
     * @return
     */
    @RequestMapping("/reload")
    public String reload(ModelMap modelMap) {
        listService.loadByFile();
        modelMap.addAttribute("title", "重新加载列表");
        return "ok";
    }
}
